﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinformMDB
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 进度条读条
        /// </summary>
        public void AddProgress(double progress, int now, int max)
        {
            this.progressBar1.Value = ((int)progress)+1;
            progressBar1.Refresh();
            label1.Text = progress.ToString() + "%";
            label1.Refresh();
            label2.Text = now.ToString() + "/" + max.ToString();
            label2.Refresh();
        }

        public void InitProgressBar(int minValue, int maxValue)
        {
            if (progressBar1 == null || minValue < 0 || maxValue < 0 || minValue >= maxValue) return;

            progressBar1.Minimum = minValue;
            progressBar1.Maximum = maxValue;
        }

        public void StartProgressBar(int value)
        {
            if (progressBar1 == null || label1 == null) return;
            Application.DoEvents();

            progressBar1.Value = value;

            int tmp = value * 100 / progressBar1.Maximum;

            label1.Text = tmp + "%";
            label1.Refresh();

            progressBar1.Refresh();
        }
    }
}   
